package org.bot.server.client;

import com.alibaba.fastjson.JSONObject;
import org.bot.client.driver.api.client.ClientOpenApi;
import org.bot.server.socket.impl.MessageType;
import org.bot.server.socket.impl.ServerWebSocket;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author 沧月
 * @create 0002 2023/10/2 12:02
 * @description <description class purpose>
 */

@Component
public class SocketServerDriverImpl implements ClientOpenApi {

    @Autowired
    ServerWebSocket serverWebSocket;

    @Override
    public boolean execute(JSONObject flowData, String clientId) {
        return serverWebSocket.sendMessage(flowData, clientId);
    }

    @Override
    public JSONObject getEventList(String clientId) {
        serverWebSocket.sendMessage(serverWebSocket
                .getMessage(MessageType.EVENT), clientId);
        return null;
    }

    @Override
    public boolean interrupt(String clientId) {
        serverWebSocket.sendMessage(serverWebSocket
                .getMessage(MessageType.INTERRUPT), clientId);
        return true;
    }
}
